package OfficeServer.report;

import java.io.Serializable;

import java.util.ArrayList;

public class Report implements Serializable {
    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    private Symptoms symptoms;

    private VitalSigns vitalSigns;

//    private Treatment[] treatments;

    private ArrayList<Treatment> treatments; 
    
    private int day;

    private double time;

    private int patient;

    private int doctor;

    private Invoice invoice;

    /**
     * Creates a new report
     * 
     * @param symptoms
     *            creates symptoms for report
     * @param vitalSigns
     *            creates new vitalSigns for report
     * @param treatments
     *            creates new treatments for report
     * @param day
     *            creates a new day for report
     * @param time
     *            creates a new time for report
     * @param patient
     *            creates a new patient for report
     * @param doctor
     *            creates a new doctor for report
     * @param invoice
     *            creates a new invoice for report
     */
    public Report(Symptoms symptoms, VitalSigns vitalSigns,
    	ArrayList<Treatment> treatments, int day, double time, int patient,
	    int doctor, Invoice invoice) {
	this.symptoms = symptoms;
	this.vitalSigns = vitalSigns;
	this.treatments = treatments;
	this.day = day;
	this.time = time;
	this.patient = patient;
	this.doctor = doctor;
	this.invoice = invoice;
    }

    /**
     * gets the symptoms
     * 
     * @return symptoms
     */
    public Symptoms getSymptoms() {
	return symptoms;
    }

    /**
     * sets the symptoms
     * 
     * @param symptoms
     */
    public void setSymptoms(Symptoms symptoms) {
	this.symptoms = symptoms;
    }

    /**
     * Sets the time
     * 
     * @param time
     *            double representing the time of the appointment
     */
    public void setTime(double time) {
	this.time = time;
    }

    /**
     * Sets the day
     * 
     * @param day
     *            The integer representation of the day of the
     *            report/appointment
     */
    public void setDay(int day) {
	this.day = day;
    }

    /**
     * Sets the patient related to the appointment
     * 
     * @param patient
     *            String representation of the Patient's name
     */
    public void setPatient(int patient) {
	this.patient = patient;
    }

    /**
     * Sets the doctor's name related to the appointment
     * 
     * @param doctor
     *            String representation of the Doctor's name
     */
    public void setDoctor(int doctor) {
	this.doctor = doctor;
    }

    /**
     * gets the vital signs
     * 
     * @return vital signs
     */
    public VitalSigns getVitalSigns() {
	return vitalSigns;
    }

    /**
     * sets the vital signs
     * 
     * @param vitalSigns
     */
    public void setVitalSigns(VitalSigns vitalSigns) {
	this.vitalSigns = vitalSigns;
    }

    /**
     * gets treatments
     * 
     * @return treatments
     */
    public ArrayList<Treatment> getTreatments() {
    	return treatments;
    }

    /**
     * sets treatments
     * 
     * @param treatments
     */
    public void setTreatments(ArrayList<Treatment> treatments) {
	this.treatments = treatments;
    }

    /**
     * gets the invoice
     * 
     * @return invoice
     */
    public Invoice getInvoice() {
	return invoice;
    }

    /**
     * sets invoice
     * 
     * @param invoice
     */
    public void setInvoice(Invoice invoice) {
	this.invoice = invoice;
    }

    /**
     * @author Chris Bayruns Deletes all records.
     */
    public void delete() {
	symptoms = null;
	vitalSigns = null;
	treatments = null;
    }

    /**
     * @return the time
     */
    public double getTime() {
	return time;
    }
    
    /**
     * Returns the copy/clone of the Report 
     * 
     * @return cloned Report
     */
    public Report clone() {
	return new Report(symptoms.clone(), vitalSigns.clone(),
		treatments, day, time, doctor, patient, invoice);
    }

    /**
     * @return the patient
     */
    public int getPatient() {
	return patient;
    }

    /**
     * @return the doctor
     */
    public int getDoctor() {
	return doctor;
    }

    /**
     * @author Chris Bayruns
     * @param update
     *            The update to report
     */
    public void updateReport(Report update) {
	ArrayList<Treatment> temp = update.getTreatments();
	this.day = update.day;
	this.time = update.getTime();

	for (Treatment t : this.treatments) {
	    for (Treatment u : temp) {
		if (t != null)
		    if (u.getTID() == t.getTID()) {
			t.update(u);
		    }
	    }
	}
	if (update != null) {
	    this.symptoms.updateSymptoms(update.getSymptoms());
	    this.vitalSigns.updateVitalSigns(update.getVitalSigns());
	    if (update.getInvoice() != null)
		this.invoice.updateInvoice(update.getInvoice());
	}
    }
}
